package com.simple.redissonrpc.core;

import cn.hutool.extra.spring.SpringUtil;
import lombok.Data;

@Data
public class GameRpcMsgContext {

    // 用于返回给调用者
    private int fromServerId;
    private long callbackId;
    private String className;
    private Object msg;

    @SuppressWarnings("all")
    public <T> T getMsg() {
        return (T) msg;
    }

    /**
     * 应答消息
     *
     * @param dataRes
     */
    public <T extends AbsRpcAnswer> void sendAnswerMsg(T dataRes) {
        RpcService rpcService = SpringUtil.getBean(RpcService.class);
        rpcService.response(fromServerId, dataRes, callbackId);
    }
}
